Problem in calling a method recursively in nodejs mongodb [closed]

Posted by Nilesh on Programmers See other posts from Programmers or by Nilesh
Published on 2012-09-20T07:26:55Z Indexed on 2012/09/20 9:51 UTC
Read the original article Hit count: 267

Filed under:
|

I am trying to create a tree using nodejs and mongodb.Wanted to show a path of a particulr node from the root.So I am finding the destination path and looping back to its parent iteratively until the root.So this is the snippet I am using which results in infinite looping

articleProvider.finditsparent(t,function(error,tap){
            if(tap[0].parent=='null')
        {
              t=(tap[0].parent);    
            console.log(n);

        }
        else
        {
          n.push(tap[0].parent);
          console.log(tap[0].parent);
          t=(tap[0].parent);
          res.send(n);
        }
        });



    res.send(n);
});

How should I get rid of this problem?Is there any way to call it recursively?

© Programmers or respective owner

Related posts about node.js

Related posts about mongodb